//
// Created by 123 on 2024/12/30.
//
#include "iostream"
using namespace std;

void swap001(int a,int b){
    int temp = a;
    a = b;
    b = temp;
}
void swap2(int* a,int* b){
    int temp = *a;
    *a = *b;
    *b = temp;
}
//引用做函数参数，引用作为变量副本，引用变了，原变量值也变了
void swap3(int& a,int& b){
    int temp = a;
    a = b;
    b = temp;
}
int main044(){
    int a = 10;
    int b = 20;
    swap001(a,b);
//    swap001(a,b);
    cout << "a==" << a << " b==" << b <<endl;
    swap2(&a,&b);
    cout << "a==" << a << " b==" << b <<endl;
    swap3(a,b);
    cout << "a==" << a << " b==" << b <<endl;


    return 0;
}